#include "DoorStatusPage.h"

#include "DoorAlertor.h"
#include "MachineDependents.h"


DoorStatusPage::DoorStatusPage(const int pageNum) : BasePage(pageNum) {
    mpControllers = &ExtendDeviceManagerSingleton::instance().getExtendDevices(ExtendDeviceEnum::DOOR_ALERTOR);
}


void DoorStatusPage::paint() {
    std::string content[4];

    resetStream();

    strStream << "doorAlertor" << std::right << std::setw(5) << pageNum;// << std::setw(3)
    content[0] = strStream.str();

    if (mpControllers->empty() ) {
        content[1] = ExtendDeviceEnum::NO_DEVICE.name;
    } else {
        ExtendDevicePtr extendDevicePtr = mpControllers->front().lock();
        if (nullptr == extendDevicePtr) {
            content[1] = ExtendDeviceEnum::NO_DEVICE.name;
        } else {

            DoorAlertor* pDoorAlertor = static_cast<DoorAlertor*> (extendDevicePtr->getDevice(ExtendDeviceEnum::DOOR_ALERTOR));

            content[1] = "status:";

            content[1].append(doorStatusVector->at(static_cast <StringVector::size_type>(pDoorAlertor->mdoorStatus)));
        }

    }
    screen.show(&content[0], &content[1], &content[2], &content[3]);
}




